package org.iteye.bbjava.util;

import java.util.HashMap;
import java.util.Map;

public enum FileType {

	JAVA, XML, JAVA_SERVER_PAGE, HTML, HTM;

	public static Map<String, String> JavaFileTypes = new HashMap<String, String>();
	public static Map<String, String> XmlFile = new HashMap<String, String>();
	public static Map<String, String> htmlFile = new HashMap<String, String>();
	public static Map<String, String> jspFile = new HashMap<String, String>();
	public static Map<String, String> htmFile = new HashMap<String, String>();

	static {
		JavaFileTypes.put("HibernateDao", "[*]HibernateDaoImpl.java");
		JavaFileTypes.put("IHibernateDao", "[*]HibernateDaoInterface.java");
		JavaFileTypes.put("MybatisDao", "[*]MybatisDaoImpl.java");
		JavaFileTypes.put("IMybatiseDao", "[*]IMybatisDao.java");
		JavaFileTypes.put("ServiceImpl", "[*]serviceImpl.java");
		JavaFileTypes.put("IService", "[*]Interface.java");
		JavaFileTypes.put("SpringMvc", "[*]Controller.java");
		JavaFileTypes.put("struct2", "[*]Action.java");

		XmlFile.put("hbm", "[*].hbm.xml");
		XmlFile.put("mapper", "[*].Mapper.xml");
		XmlFile.put("xml", "[*].xml");
		XmlFile.put("xsl", "[*].xsl");
		XmlFile.put("struct2", "Struct.xml");
		XmlFile.put("spring", "applicationContext-[*].xml");
		XmlFile.put("mybatis", "configuration-[*].xml");

		htmlFile.put("list", "[*]List.html");
		htmlFile.put("detail", "[*]Detail.html");
		htmlFile.put("add", "[*]AddInput.html");
		htmlFile.put("delete", "[*]Delete.html");
		htmlFile.put("update", "update[*].html");

		htmFile.put("list", "[*]List.htm");
		htmFile.put("detail", "[*]Detail.htm");
		htmFile.put("add", "[*]AddInput.htm");
		htmFile.put("delete", "[*]Delete.htm");
		htmFile.put("update", "update[*].htm");

		jspFile.put("list", "[*]List.jsp");
		jspFile.put("detail", "[*]Detail.jsp");
		jspFile.put("add", "[*]AddInput.jsp");
		jspFile.put("delete", "[*]Delete.jsp");
		jspFile.put("update", "update[*].jsp");

	}

	/**
	 * get fileType by name
	 * 
	 * @author zhang
	 * @param name
	 *            <code>name</code>
	 * */
	public Map<String, String> getMapByName(String name) {
		Map<String, String> map = null;
		if (null != name && !"".equals("")) {
			if (name.equals(FileType.JAVA)) {
				map = JavaFileTypes;
			}
			if (name.equals(FileType.JAVA_SERVER_PAGE)) {
				map = jspFile;
			}
			if (name.equals(FileType.XML)) {
				map = XmlFile;
			}
			if (name.equals(FileType.HTML)) {
				map = htmlFile;
			}
			if (name.equals(FileType.HTM)) {
				map = htmFile;
			}
		}
		return map;
	}

}
